# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=datovka
pkgver=4.23.0
pkgrel=0
pkgdesc="A free graphical interface for Czech Databox"
url="https://www.datovka.cz/"
arch="all"
license="GPL-3.0-or-later WITH cryptsetup-OpenSSL-exception"
makedepends="
	desktop-file-utils
	libdatovka-dev
	openssl-dev
	qt6-qt5compat-dev
	qt6-qtbase-dev
	qt6-qtsvg-dev
	qt6-qtwebsockets-dev
	quazip-dev
	zlib-dev
	"
subpackages="$pkgname-doc"
source="https://secure.nic.cz/files/datove_schranky/$pkgver/datovka-$pkgver.tar.xz
	disable-test_crypto_pin_pwd.patch
	"

prepare() {
	default_prepare

	# XXX: This enables '#define _Bool bool' which is needed on Alpine.
	sed -i 's/#if defined(__APPLE__) || defined(__clang__)/& || true/' \
		config.tests/libdatovka/*.cpp \
		src/*.cpp \
		src/*.h \
		src/isds/*.cpp \
		src/isds/*.h \
		src/datovka_shared/isds/*.h \
		tests/*.cpp

	# Fedora dropped them too, claiming that upstream had been notified.
	rm -f tests/test_crypto_message.pri tests/test_isds_message.pri
}

build() {
	export CFLAGS="$CFLAGS -flto=auto"
	export CXXFLAGS="$CXXFLAGS -flto=auto"

	qmake6 PREFIX=/usr DISABLE_VERSION_CHECK_BY_DEFAULT=1
	make
}

check() {
	cd tests
	qmake6 tests.pro PREFIX=/usr
	make
	./tests
}

package() {
	make install INSTALL_ROOT="$pkgdir"
	desktop-file-validate "$pkgdir"/usr/share/applications/$pkgname.desktop
}

sha512sums="
2cfb59e6d9704261845aaf30e0afc369e807150e8995c730c7b325a9889e6c0306626996a260d81f88d33b752c08978d7bff23bc6f0747ced714f5cbe508ca43  datovka-4.23.0.tar.xz
ff0d49238fa5e2bf7c6f22f09c23453bf7b39f4252285e86c8bfa140be76b4b82122d4c9548fb6ab6009a5d071b2195a64b2226b5e295ce5f8c11e83c74b4448  disable-test_crypto_pin_pwd.patch
"
